This is a creation in
Article, where the information may have evolved or changed. # # What is Protobufprotobuf (Protocol Buffer) is a data interchange format for Google, which is independent of the language and platform-independent. Google offers implementations in multiple languages: Java, C #, C + +, go and Python, each of which contains compilers and library files for the appropriate language. Because it is a binary format, it is much faster than
article: Json-rpc:a Tale of interfaces.
PROTOBUF-based RPC calls
PROTOBUF is a coding protocol developed by Google. Its advantage is that the encoded data volume is small (not compression algorithm), more suitable for the command of the transmission encoding.
The PROTOBUF official team offers support in several languages Java/c++/python, and the
This is a creation in
Article, where the information may have evolved or changed.
1. Compile and install Protobuf (protobuf no release on Go)
为了从源码安装protobuf,先要安装一些工具:包括autoconf、automake、libtool、curl(用于下载gmock)、make、 g++、 unzip。 在ubuntu可以使用如下命令安装这些依赖:
sudo apt-get install autoconf automake libtool curl make
Go to the official website first download PROTOBUF source codeHttps://github.com/google/protobuf/releasesYou can download the local and upload to the virtual machine firstI chose source code (tar.gz).Install a dependent package (error may occur if a package is missing)Yum install-y gcc gcc-c++ autoconf automake Libtool Curl Make g++ UnzipAfter decompression, ent
This is a creation in
Article, where the information may have evolved or changed.
Why is there a lot of almost identical and incorrect tutorials on the Internet???
Fucking Open a tutorial about Golang and protobuf, nothing more than to pull the fuck protobuf how awesome, how stupid xml, and then how to install Protobuf, and then the same shit as an example.
Insta
This is a creation in
Article, where the information may have evolved or changed.
Protobuf for Golang through plug-in support, because some need to install PROTOC execution Environment, below we take a step-by-step look at, how to build a compilation environment.
1. Installing PROTOC
2. Download and install the Protobuf-go plugin
Download the plugin from GitHub
This is a created
article in which the information may have evolved or changed.
Since the extranet is often blocked, the go version of PROTOBUF is downloaded to the local, basically protobuf-master.zip this form.
The download address for the go version of Protobuf is
This is a creation in
Article, where the information may have evolved or changed.
The go language version of the PROTOBUF-RPC is basically complete. Now let's simply say how to use it.
Install the test environment
Download the code first (not supported go get ):
hg clone https://bitbucket.org/chai2010/gopath
Then the downloaded directory is set to GOPATH , a
This is a created
article in which the information may have evolved or changed.
1.https://github.com/google/protobuf/releases/tag/v3.0.0 Download the required version, if autoreconf not found error occurs during the execution of Autogen.sh, Instructions are not installed Automake, in Ubuntu execute sudo apt-get install Automake libtool on it, other platforms are installed according to the actual situation.
2. Execute
Let's not talk nonsense.1. Install: Download down, find a path to put it. Https://github.com/golang/protobufThis is not enough because you will find that you cannot use Protoc to download the C + + version to Protobuf website, see readme,./configure make make install.2. Use: Write a proto file, the beginning of the file to indicate PackageName and then runProtoc--go_out=src/proto Proto/*. ProtoWhen used, the import corresponds to the proto PackageNa
This is a creation in
Article, where the information may have evolved or changed.
MQ Framework for multiple persistence scenarios based on GO+PROTOBUF: Kiteq
Gitlab found a relatively good open source project, hereby introduced:
Brief introduction
* 基于zk维护发送方、订阅方、broker订阅发送关系、支持水平、垂直方面的扩展* 基于与topic以及第二级messageType订阅消息* 基于mysql、文件存储方式多重持久层消息存储* 保证可靠异步投递* 支持两阶段提交分布式事务
Engineering structure
kiteq/├──readm
Google's official support.Download: https://code.google.com/p/protobuf/downloads/listAfter the decompression is like this (2.5.0):Go to the "Protobuf-2.5.0\java" folder, which is a MAVEN project that you directly use Maven clean Install in the target directory will generate a Protobuf-java-2.5.0.jar jar package, no ma
--------------------------------------------------------------------------------------------------------------- ----------------------------------------------------Earlier in the company to transplant the project to iOS, but protobuf, but there is no use of the situation, and later found on the Internet solution, thank the great God.------------------------------------------------------------------------------------------------------ -----------------
, with Google's official support.Download: https://code.google.com/p/protobuf/downloads/listAfter the decompression is like this (2.5.0):Go to the "Protobuf-2.5.0\java" folder, which is a MAVEN project that you directly use Maven clean Install in the target directory will generate a Protobuf-java-2.5.0.jar jar package,
Protocol buffers (PROTOBUF) Official Document--PROTOBUF language guideConvention: For the convenience of writing, protocolbuffers in the following will have PROTOBUF replaced.This guide will describe how to use protobuf to define I structured protobuf data, including the. pr
directory, and then using the command line to enter the installation package directory. Execution instructions:python setup.py install;
Protobuff: First, we will download the good source package Protobuf-2.5.0.zip and compile the package protoc-2.5.0-win32.zip Unzip the package to the specified directory, the path is best not to include Chinese;
Here I decompression Protobuf-2.5.0.zip to the po
(...) // depending on your network implementation request-> serializetozerocopystream ( outputstream); _ connection-> postdata (outputstream. getdata (),......}Server
The server first needs to implement the RPC interface to directly implementMyServiceInterface defined in:
class MyServiceImpl : public MyService { virtual void Echo(::google::protobuf::RpcController* controller, const EchoReqMsg* request, EchoRespMsg* respon
C ++ uses protobuf to transmit a byte array containing \ 0 in the middle, and a protobuf Array
The C ++ implementation of protocol buffers returns the byte and string typesStd: string. This structure contains a length function telling you how long the corresponding data is (as well as the data itself.) Thus there is no special significance of embeded\ 0Characters.
The setting functions accept a string too
the target language (C++,java,python), is a format defined by Google Protobuf. in fact, this file is not necessary, compile protobuf-2.6.1.tar.bz2 will generate this EXE)Go to the official website to download Protobuf source code and compile tool: Https://developers.google.com/protocol-buffers/docs/downloadsThen unzip
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.